<template>
    <div style="height:100%;width:100%;">
        <bar class="bar" @on-back="$router.back()" title="修改登录密码"> </bar>
        <div class="youba-primary-grey" style="height: 60px; text-align: center; line-height: 60px">请输入新的登录密码</div>
        <group>
            <mu-input placeholder="请输入新密码" type="text" v-model="newPassword" class="my-edit-name"></mu-input>
        </group>
        <div class="my-input">
            <x-button @click.native="handle" class="login-submit">确定</x-button>
        </div>
    </div>
</template>

<script>
    import {mapState} from 'vuex'
    import {mapMutations} from 'vuex'
    import VUEX_NAME from '../../../store/constants.vue'
    import {
        lang
    } from 'muka'
    import {
        Bar,
        MInput
    } from 'muka-ui'
    import {
        Group,
        XButton,
        Msg
    } from 'vux'
    import md5 from 'js-md5'
    export default {
        name: 'editName',
        components: {
            Bar,
            'mu-input': MInput,
            Group,
            XButton,
            Msg
        },
        created: function () {
        },
        data: function () {
            return {
                newPassword: '',
            }
        },computed: mapState([
            VUEX_NAME.sessionId,
        ]),
        methods: {
            ...mapMutations([
                VUEX_NAME.modifySessionId,
            ]),
            handle: function () {
                if (!this.newPassword) {
                    this.$vux.toast.show({
                        text: '请输入新密码',
                        type: 'text',
                        position: 'middle'
                    })
                    return
                }
                this.$ajax(
                    'safe/changePwd',
                    {
                        sessionId: this.sessionId,
                        newPassword: md5(this.newPassword)
                    },
                    (content) => {
                        this.$router.go(-2)
                    }, true, true)
            }
        }
    }

</script>
<style lang="less">
    .myInfo-confirm {
        .weui-dialog__btn_default {
            display: none;
        }
    }

</style>
